package com.example.demo.web.common.gateway;

import java.util.function.Predicate;
import org.noear.solon.Solon;
import org.noear.solon.core.BeanWrap;
import org.noear.solon.core.handle.Filter;
import org.noear.solon.core.handle.Gateway;

/**
 * @author airhead
 */
public abstract class BaseGateway extends Gateway {
  public void addFilters(Predicate<BeanWrap> where) {
    Solon.context()
        .lifecycle(
            () ->
                Solon.context()
                    .beanForeach(
                        (bw) -> {
                          if (where.test(bw)) {
                            if (bw.raw() instanceof Filter) {
                              filter(bw.index(), bw.raw());
                            }
                          }
                        }));
  }
}
